package com.hzj.recipe.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import lombok.Data;

/**
 * 食谱-食材关联表
 * @TableName recipe_ingredient
 */
@TableName(value ="recipe_ingredient")
@Data
public class RecipeIngredient implements Serializable {
    /**
     * 关联表id
     */
    @TableId(value = "relation_id")
    private Integer relationId;

    /**
     * 食谱id
     */
    @TableField(value = "recipe_id")
    private Integer recipeId;

    /**
     * 食材id
     */
    @TableField(value = "ingredient_id")
    private Integer ingredientId;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        RecipeIngredient other = (RecipeIngredient) that;
        return (this.getRelationId() == null ? other.getRelationId() == null : this.getRelationId().equals(other.getRelationId()))
            && (this.getRecipeId() == null ? other.getRecipeId() == null : this.getRecipeId().equals(other.getRecipeId()))
            && (this.getIngredientId() == null ? other.getIngredientId() == null : this.getIngredientId().equals(other.getIngredientId()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getRelationId() == null) ? 0 : getRelationId().hashCode());
        result = prime * result + ((getRecipeId() == null) ? 0 : getRecipeId().hashCode());
        result = prime * result + ((getIngredientId() == null) ? 0 : getIngredientId().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", relationId=").append(relationId);
        sb.append(", recipeId=").append(recipeId);
        sb.append(", ingredientId=").append(ingredientId);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}